﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Account.aspx.cs" Inherits="Account" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <div style="text-align:left">
        <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="1" 
            Width="800px" Height="650px">
            <asp:TabPanel runat="server" HeaderText="My Details" ID="SettingsTabPanel">
            <ContentTemplate>
                <asp:Panel ID="Panel1" runat="server" BackColor="#CECECE" Height="650px" Width="780px">
                    <br /><br /><div style="text-align:center"><h3>My Details</h3></div><br /><br />
                    <asp:Panel ID="FirstNamePanel" runat="server">
                        First Name:
                        <asp:Label ID="SettingsFirstNameLabel" runat="server" Text="" />
                        <hr />
                    </asp:Panel>
                    <br /><br /><br /><br />
                    <asp:Panel ID="LastNamePanel" runat="server">
                        Last Name:
                        <asp:Label ID="SettingsLastNameLabel" runat="server" Text="" />
                        <hr />
                    </asp:Panel>
                    <br /><br /><br /><br />
                    <asp:Panel ID="EmailPanel" runat="server">
                        Email:
                        <asp:Label ID="SettingsEmailLabel" runat="server" Text="" />
                        <hr />
                    </asp:Panel>
                    <br /><br /><br /><br />
                    <asp:Panel ID="PhoneNumberPanel" runat="server">
                        Phone Number:
                        <asp:Label ID="SettingsPhoneNumberLabel" runat="server" Text='<%# Eval("FirstName") %>' />
                        <hr />
                    </asp:Panel>
                    <br /><br /><br /><br />
               </asp:Panel>
                <asp:ObjectDataSource ID="MyDetailsDS" runat="server" SelectMethod="getUser"
                TypeName="ForumLibrary.Data.ForumWebManager">
                    <SelectParameters>
                        <asp:SessionParameter Name="username" SessionField="username" Type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </ContentTemplate>
            </asp:TabPanel>
    
            <asp:TabPanel ID="FriendsTabPanel" runat="server" HeaderText="Friends">
            <ContentTemplate>
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                        <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="4">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            </Fields>
                        </asp:DataPager>
                        <asp:ListView ID="ListView1" runat="server" DataSourceID="FriendsDS" 
                            onitemdeleting="ListView1_ItemDeleting">
                            <ItemTemplate>
                                <ajaxToolkit:CollapsiblePanelExtender ID="FriendPanelExtender" runat="server"
                                TargetControlID="DetailsPanel"
                                ExpandControlID="UsernamePanel"
                                CollapseControlID="UsernamePanel"
                                Collapsed="true"
                                TextLabelID="UsernameLabel"
                                ImageControlID="Image1"
                                ExpandedImage="~/Resources/img/collapse_blue.jpg"
                                CollapsedImage="~/Resources/img/expand_blue.jpg"
                                SuppressPostBack="true">
                                </ajaxToolkit:CollapsiblePanelExtender>
                                <asp:Panel ID="UsernamePanel" runat="server" CssClass="collapsePanelHeader" BackImageUrl="~/Resources/img/bg-menu-main.png" Width="780px">
                                    <asp:Image ID="Image1" runat="server" ImageUrl="~/Resources/img/expand_blue.jpg" ImageAlign="Right"/>
                                    <asp:Label ID="UsernameLabel" runat="server" Text='<%# Eval("Username") %>' />
                                </asp:Panel>
                                <fieldset>
                                <asp:Panel ID="DetailsPanel" runat="server" CssClass="collapsePanel">
                                    <span style="">
                                        First Name:
                                        <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
                                        <br />
                                        Last Name:
                                        <asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' />
                                        <br />
                                        Email:
                                        <asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' />
                                        <br />
                                        Phone Number:
                                        <asp:Label ID="PhoneNumberLabel" runat="server" Text='<%# Eval("PhoneNumber") %>' />
                                        <br />
                                        <asp:Label ID="IsConnected" runat="server" Text='<%# (bool)Eval("LoggedIn") ? "Connected" : "Not Connected" %>' />
                                        <br />
                                        <br />
                                    </span>
                                    <asp:Button ID="RemoveButton" runat="server" Text="RemoveFriend" onclick="RemoveFriend_Click" CommandArgument='<%# Eval("Username") %>'/>
                                </asp:Panel>
                                </fieldset>
                            </ItemTemplate>
                            <LayoutTemplate>
                                <div ID="itemPlaceholderContainer" runat="server" style="">
                                    <span runat="server" id="itemPlaceholder" style="" />
                                </div>
                            </LayoutTemplate>
                        </asp:ListView>
                        <asp:ObjectDataSource ID="FriendsDS" runat="server" SelectMethod="getFriends" 
                            TypeName="ForumLibrary.Data.ForumWebManager" InsertMethod="addFriend" 
                            DeleteMethod="removeFriend" ondeleting="FriendsDS_Deleting">
                            <DeleteParameters>
                                <asp:Parameter Name="friendRemoving" Type="String" />
                                <asp:Parameter Name="friendRemoved" Type="String" />
                            </DeleteParameters>
                            <InsertParameters>
                                <asp:Parameter Name="friendAdding" Type="String" />
                                <asp:Parameter Name="friendAdded" Type="String" />
                            </InsertParameters>
                            <SelectParameters>
                                <asp:SessionParameter Name="username" SessionField="username" Type="String" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </ContentTemplate>
            </asp:TabPanel>
            <asp:TabPanel ID="SearchForFriendPanel" runat="server" HeaderText="AddFriends">
                <ContentTemplate>
                    <br /><br />
                    <div style="text-align:center">
                        <h3>Search For A Friend</h3>
                        <asp:TextBox ID="SearchTextBox" runat="server"></asp:TextBox> 
                        <asp:Button ID="SearchButton" runat="server" Text="Search" 
                            onclick="SearchButton_Click" />
                    </div>
                    <div style="text-align:left">
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <Triggers><asp:AsyncPostBackTrigger ControlID="SearchButton" EventName="Click" /></Triggers>
                            <ContentTemplate>
                                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                                    DataSourceID="SearchDS" 
                                    onselectedindexchanging="GridView1_SelectedIndexChanging" 
                                    BorderColor="Black" BorderStyle="Double" AllowPaging="True" PageSize="5">
                                    <Columns>
                                        <asp:CommandField SelectText="Add Friend" ShowSelectButton="True" />
                                        <asp:BoundField DataField="Username" HeaderText="Username" 
                                            SortExpression="Username" />
                                        <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                                            SortExpression="FirstName" />
                                        <asp:BoundField DataField="LastName" HeaderText="LastName" 
                                            SortExpression="LastName" />
                                        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                                        <asp:BoundField DataField="PhoneNumber" HeaderText="PhoneNumber" 
                                            SortExpression="PhoneNumber" />
                                        <asp:CheckBoxField DataField="Moderator" HeaderText="Moderator" 
                                            SortExpression="Moderator" />
                                        <asp:CheckBoxField DataField="LoggedIn" HeaderText="LoggedIn" 
                                            SortExpression="LoggedIn" />
                                    </Columns>
                                </asp:GridView>
                                <asp:ObjectDataSource ID="SearchDS" runat="server" 
                                    SelectMethod="searchForNewFriend" TypeName="ForumLibrary.Data.DataManager">
                                    <SelectParameters>
                                        <asp:SessionParameter Name="username" SessionField="username" Type="String" />
                                        <asp:ControlParameter ControlID="SearchTextBox" DefaultValue="&quot;&quot;" 
                                            Name="searchedUser" PropertyName="Text" Type="String" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                </ContentTemplate>
            </asp:TabPanel>
        </ajaxToolkit:TabContainer>
    </div>
</asp:Content>

